package com.pi.smart.wxmini.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pi.base.dto.result.AppResult;
import com.pi.http.base.controller.BaseController;
import com.pi.uc.service.UcUserShareService;

@RequestMapping("/share")
@RestController
public class SmartShareController extends BaseController{
  private static final Logger logger = LoggerFactory.getLogger(SmartShareController.class);
  @Autowired
  private UcUserShareService userShareService;
  
  /**
   * @description 生成分享id
   * @return
   */
  @PostMapping("/generate")
  public AppResult genereateShare(){
    Long shareId = userShareService.generateShare(getLoginUserId());
    logger.info("返回的分享编号: {}", shareId);
    return AppResult.newSuccessResult(shareId);
  }
  
  /**
   * @description 添加分享关联
   * @return
   */
  @PostMapping("/bind")
  public AppResult genereateShare(Long shareId){
    userShareService.bindShare(shareId, getLoginUserId());
    return AppResult.newSuccessResult(shareId);
  }
}
